﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/MasterPages/Dialog.Master" AutoEventWireup="true" CodeBehind="UploadFile.aspx.cs" Inherits="DMS.Web.Common.ApplicationPages.UploadFile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
    文件上传
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainHolder" runat="server">
    <fieldset>
    <legend>
        <asp:Label ID="lblUploadTitle" runat="server">请选择需要上传的文件</asp:Label>
    </legend>
    <div style="padding-top: 5px;">
        <div style="padding-top: 5px; padding-left: 5px; padding-bottom: 10px;">
            <asp:FileUpload ID="fuSelector" runat="server" Width="95%" />
            <div style="padding-top: 5px;padding-bottom:5px">
                <span>说明：请点击“浏览”选择需要上传的文件，文件大小不能超过<%=MaxUploadSize/1024%>KB，仅支持上传：<%=AllowFileTypes %>文件。</span>
                <span id="spRemark" runat="server"></span>
                <span id="DocuInfo" style="display:none" runat="server"><br/>点击<a href="#" style="text-decoration:none; " id="DocuLinnk" runat="server" target="_blank">下载“<b style="color:Red" id="DocuName" runat="server">报废更新模板</b>”</a></span>
            </div>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请先选择文件，再点击保存！"
                ControlToValidate="fuSelector" Display="Dynamic" ForeColor="red"></asp:RequiredFieldValidator>
            <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="fuSelector" ForeColor="red"
                Display="Dynamic" ErrorMessage="不允许上传该格式的文件，请重新选择。" ClientValidationFunction="CheckFileType"></asp:CustomValidator>
            <asp:CustomValidator ID="CustomValidator2" runat="server" ControlToValidate="fuSelector" ForeColor="red"
                Display="Dynamic" ErrorMessage="不允许上传该格式的文件，请重新选择。" ClientValidationFunction="CheckFileSize"></asp:CustomValidator>
        </div>
    </div>
</fieldset>


<script language="javascript" type="text/javascript">
<!--
    function CheckFileType(source, clientside_arguments) {
        var fu = document.getElementById("<%=fuSelector.ClientID %>");
        var typeList = "<%=AllowFileTypes %>";
        if (fu.value == "" || typeList == "") {
            clientside_arguments.IsValid = true;
            return true;
        }
        
        var pointIndex = fu.value.lastIndexOf(".");
        var endIndex = fu.value.length;
        if (pointIndex <= 0 || endIndex <= pointIndex) {
            clientside_arguments.IsValid = false;
            return false;
        }

        var ext = fu.value.substring(pointIndex, endIndex) + ";";
        if (typeList.toLowerCase().indexOf(ext.toLowerCase()) == -1) {
            clientside_arguments.IsValid = false;
            return false;
        }

        clientside_arguments.IsValid = true;
        return true;
    }
    function CheckFileSize(source, clientside_arguments) {

        var fu = document.getElementById("<%=fuSelector.ClientID %>");
        var sizeLimit = <%=MaxUploadSize %>;
        if (fu.value == "") {
            clientside_arguments.IsValid = true;
            return true;
        }
        
        if (fu.size > sizeLimit) {
            clientside_arguments.IsValid = false;
            return false;
        }

        clientside_arguments.IsValid = true;
        return true;
    }
//-->
</script>
    
</asp:Content>

<asp:Content ID="ctFooter" ContentPlaceHolderID="FooterHolder" runat="server">
    <asp:LinkButton ID="btnSave" CssClass="linkbtn" CanDisplay="New,Edit" runat="server"
        OnClick="btnSave_Click" CausesValidation="true"><span>保存</span></asp:LinkButton>&nbsp;&nbsp;
    <a href="javascript:window.returnValue='';window.close();" class="linkbtn"><span>关闭</span></a>
</asp:Content>